package com.sky.mapper;

import com.sky.anno.AutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SetmealMapper {
    List<SetmealVO> selectPage(SetmealPageQueryDTO setmealPageQueryDTO);
    @AutoFill(OperationType.INSERT)
    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("Insert into setmeal (category_id, name, price, description, image, create_time, update_time, create_user, update_user,status)" +
            "values (#{categoryId},#{name},#{price},#{description},#{image},#{createTime},#{updateTime},#{createUser},#{updateUser},#{status})")
    void saveSetmeal(Setmeal setmeal);
    @Update("update setmeal set status=#{status} where id=#{id}")
    void satrtOrStop(Integer status, Long id);

    void batchDelete(List<Long> ids);
    @Select("select *from setmeal where id=#{id}")
    SetmealVO selectSetmealById(Long id);
    @Update("update setmeal set category_id=#{categoryId},name=#{name},price=#{price},description=#{description},image=#{image},update_time=#{updateTime},update_user=#{updateUser} where id =#{id}")
    void updateSetmeal(Setmeal setmeal);
    @Select("select *from setmeal where category_id=#{id}")
    List<Setmeal> selectById(Integer id);
}
